#include "../maze.h"
#include "../wall.h"
#include "../room.h"
#include "../door.h"
#include "standartmazebuilder.h"

StandartMazeBuilder::StandartMazeBuilder()
{
    _currentMaze = 0;
}

void StandartMazeBuilder::buildMaze()
{
    _currentMaze = new Maze;
}

void StandartMazeBuilder::buildRoom(int room)
{
    if (!_currentMaze->roomNo(room))
    {
        Room *r = new Room(room);
        _currentMaze->addRoom(r);

        r->setSide(D_North, new Wall);
        r->setSide(D_South, new Wall);
        r->setSide(D_East, new Wall);
        r->setSide(D_West, new Wall);
    }
}

void StandartMazeBuilder::buildDoor(int roomFrom, int roomTo)
{
    Room *r1 = _currentMaze->roomNo(roomFrom);
    Room *r2 = _currentMaze->roomNo(roomTo);
    Door *d = new Door(r1, r2);

    r1->setSide(commonWall(r1, r2), d);
    r2->setSide(commonWall(r2, r1), d);
}

Maze *StandartMazeBuilder::maze()
{
    return _currentMaze;
}

Direction StandartMazeBuilder::commonWall(Room *r1, Room *r2)
{
    // TODO: add implementation
}
